﻿@{
    ViewBag.Title = "TypeForm";
    Layout = "~/Views/Shared/_Form.cshtml";
}@using LeSoft.Application.Code;
<script>
    var keyValue = request('keyValue');
    $(function () {
        initControl();
    })
    //初始化控件
    function initControl() {
        //上级
        $("#ParentId").ComboBoxTree({
            url: "../../ResourceManage/RS_Product/GetTypeTreeJson",
            description: "==请选择==",
            height: "180px",
            click: function () {
                var type = $("#ParentId").attr('data-value');
                $.ajax({
                    url: "../../ResourceManage/RS_Warehouse/ChkType",
                    type: "post",
                    dataType: "text",
                    data: { key: "ProductType", Type: type },
                    success: function (data) {
                        if (data != "") {
                            dialogMsg(data, 0)
                        }
                    }
                })
            }
        });
        //获取表单
        if (!!keyValue) {          
            $.SetForm({
                url: "../../ResourceManage/RS_Product/GetTypeFormJson",
                param: { keyValue: keyValue },
                success: function (data) {
                    $("#ProductType").SetWebControls(data);
                  
                }
            });
        } 
    }

    //保存表单
    function AcceptClick() {
        if (!$("#ProductType").Validform()) {
            return false;
        }
        var postData = $("#ProductType").GetWebControls(keyValue);
        if (postData["ParentId"] == "") {
            postData["ParentId"] = 0;
        }
        $.SaveForm({
            url: "../../ResourceManage/RS_Product/SaveTypeForm?keyValue=" + keyValue,
            param: postData,
            loading: "正在保存数据...",
            success: function () {
                top.frames["TypeIndex"].$("#gridTable").trigger("reloadGrid"); 
                dialogClose()
            }
        })
    }
</script>
<div style="width:90%; margin-top:10px;" >
    <table class="form" id="ProductType" style="margin:0px auto;">      
        <tr>
            <td class="formTitle">名称<font face="宋体">*</font></td>
            <td class="formValue">
                <input id="Name" type="text" class="form-control" placeholder="请输入名称" isvalid="yes" checkexpession="NotNull" />
            </td>
        </tr>
        <tr>
            <td class="formTitle">编号<font face="宋体">*</font></td>
            <td class="formValue">
                <input id="Code" type="text" class="form-control" placeholder="请输入编号" isvalid="yes" checkexpession="NotNull" />
            </td>
        </tr>
        <tr>
            <th class="formTitle">父类</th>
            <td class="formValue">
                <div id="ParentId" type="selectTree" class="ui-select"></div>
            </td>
        </tr>
        <tr>
            <td class="formTitle" style="height: 37px;">有效</td>
            <td class="formValue">
                <div class="checkbox">
                    <label>
                        <input id="EnabledMark" type="checkbox" checked="checked" />
                        有效
                    </label>
                </div>
            </td>
        </tr>
        <tr>
            <th class="formTitle" valign="top" style="padding-top: 4px;">
                备注 
            </th>
            <td class="formValue">
                <textarea id="Description" class="form-control" style="height: 70px;"></textarea>
            </td>
        </tr>
    </table>
</div>

